!{include file='common/iheader.htm'}
<link rel="stylesheet" href="!{res file='js/jquery_plus/Jcrop/jquery.Jcrop.css'}" type="text/css" />
<div id="i_nav">
	<h3 class="page_title">引用管理</h3>
	<a class="button" href="/manager.php?app=wiki">WIKI管理</a>
	<a class="button" href="/manager.php?app=wiki&act=recommend&type=0">引用管理</a>
</div>
<h1>!{$recommend.title}</h1>
<p>!{$recommend.desc}</p>
<form id="image_edit_form">
	<img id="jcrop_box" src="!{res file=$recommend.src_image thumb=680x680}"/>
	<div class="form_item form_btn_item">
		<input type="button" value="保存" class="button submit_btn">
	</div>
</form>
<script src="!{res file='js/jquery_plus/Jcrop/jquery.Jcrop.min.js'}"></script>
<script>
	var data = null;
	$(function(){
		$('#jcrop_box').Jcrop({
			aspectRatio : !{$width} / !{$height},
			minSize : [!{$width}, !{$height}],
			onChange : function(c){
				// c.x, c.y, c.x2, c.y2, c.w, c.h
				data = c;
			}
		});
		
		$('.submit_btn').click(function(){
			if(data === null){
				alert('您还没有编辑过图片！');
				return;
			}
			$.post('/manager.php?app=wiki&act=edit_recommend_image',{
				id : '!{$smarty.request.id}',
				rid : '!{$smarty.request.rid}',
				x : data.x,
				y : data.y,
				x2 : data.x2,
				y2 : data.y2,
				w : data.w,
				h : data.h
			},function(data){
				var json = eval('(' + data + ')');
				if(json.result){
					window.location.href = '/manager.php?app=wiki&act=recommend&type=!{$type}';
				}else{
					alert(json.info);
				}
			});
		});
	});
</script>
!{include file='common/ifooter.htm'}